package cn.wit.test;

/**
 * 编写一个方法，输入年份和月份，返回该月有多少天
 * 
 * @author 16604
 *
 */

public class DemoDays {
	public static void main(String[] args) {

		int year = 2000;
		int month = 2;
		System.out.println(getDays(year, month));

	}

	public static int getDays(int year, int month) {
		int days = 0;

		// 先是判断是不是闰年
		if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
			if (month == 2) {
				days = 29;
				return days;
			}
		} else { // 如果不是闰年
			if (month == 2) {
				days = 28;
				return days;
			}
		}
		switch (month) {
		case 1:
		case 3:
		case 5:
		case 7:
		case 8:
			days = 31;
			break;
		case 4:
		case 6:
		case 9:
		case 10:
		case 12:
			days = 30;
			break;
		}
		return days;
	}

}
